<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<base href="<%=basePath%>">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<title>记者投稿系统</title>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<link rel="stylesheet" href="css/style.css" />

<body>

<div class="login-container">
	<h1>记者投稿系统</h1>

	<div class="connect">
		<p>欢迎来到记者投稿系统</p>
	</div>

	<form id="loginForm">
		<div>
			<input type="text" name="userName" class="username" placeholder="用户名" autocomplete="off"/>
		</div>
		<div>
			<input type="password" name="password" class="password" placeholder="密码" oncontextmenu="return false" onpaste="return false" />
		</div>
		<button id="submit" type="button" onclick="login()">登 录</button>

	</form>
	    <a href="register.jsp">
		  <button type="button" onclick="window.location='register.jsp'" class="register-tis">还有没有账号？</button>
	   </a>
</div>

<script src="js/jquery.min.js"></script>
<script src="js/common.js"></script>
<!--背景图片自动更换-->
<script src="js/supersized.3.2.7.min.js"></script>
<script src="js/supersized-init.js"></script>
<!--表单验证-->
<script src="js/jquery.validate.min.js?var1.14.0"></script>
<script type="text/javascript">
    function login(){
        debugger;
        var userName = $("input[name='userName']").val();
        var password = $("input[name='password']").val();

        $.ajax({
            url: '/user/userLogin',
            type: 'POST',
            dataType: 'json',
            data: "userName=" + userName + "&password=" + password,
            success:function (data) {


                if (data == null) {
                    alert("用户名或密码错误");
                } else {
                    alert("登陆成功");
                    window.location = "home.jsp";
                }
            },
        });

    }
</script>
</body>
</html>